package com.kalix.training.imgs.biz;

import com.kalix.framework.core.api.persistence.JsonData;
import com.kalix.framework.core.impl.biz.ShiroGenericBizServiceImpl;
import com.kalix.training.imgs.api.biz.IImgsBeanService;
import com.kalix.training.imgs.api.dao.IImgsBeanDao;
import com.kalix.training.imgs.entities.ImgsBean;

import java.util.List;

public class ImgsBeanServiceImpl extends ShiroGenericBizServiceImpl<IImgsBeanDao, ImgsBean>
        implements IImgsBeanService {
    @Override
    public JsonData getImgByType(String type, String identify) {
        String sql="select m from ImgsBean m where 1=1";
        if ( type !=null && !type.equals("")) {
            sql += " and m.type='"+type+"'";
        } else if(identify !=null && !identify.equals("")) {
            sql += " and m.identify='"+identify+"'";
        } else {
        }
        sql += " order by m.identify";
        List<ImgsBean> list = dao.find(sql);
        JsonData jsonData = new JsonData();
        jsonData.setData(list);
        jsonData.setTotalCount((long)list.size());
        return jsonData;
    }
}
